import Qt 4.7

Item {
    property variant model: null
    property int currentIndex: 0
    property alias interval: bgImgChangeTimer.interval
    property int delay: 300

    Image {
        id: bgImg1
        source: model != null ? model[currentIndex] : ""
        opacity: 1.0
        anchors.fill: parent
        Behavior on opacity { PropertyAnimation {duration: delay} }
        onOpacityChanged: {
            if(opacity <= 0.0)
            {
                if(currentIndex < model.length - 1)
                    currentIndex++;
                else
                    currentIndex = 0;
            }
        }
    }
    Image {
        id: bgImg2
        source: (model != null) && (currentIndex >= (model.length - 1)) ?
                    model[0] : model[currentIndex]
        anchors.fill: parent
        Behavior on opacity { PropertyAnimation {duration: delay} }
        opacity: 0.0
        onOpacityChanged: {
            if(opacity <= 0.0)
            {
                if(currentIndex < model.length - 1)
                    currentIndex++;
                else
                    currentIndex = 0;
            }
        }
    }
    Timer {
        id: bgImgChangeTimer
        interval: 3000
        repeat: true
        running: true
        onTriggered: {
            if(bgImg1.opacity > 0.0) {
                bgImg1.opacity = 0.0; bgImg2.opacity = 1.0;
            } else {
                bgImg1.opacity = 1.0; bgImg2.opacity = 0.0;
            }
        }
    }
}
